<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta name="viewport" content="width=device-width; initial-scale=1.0" />	
	<link rel="stylesheet" href="__RES__/common/base.css" />
	<link rel="stylesheet" href="__RES__/member/css/reg.css" />
</head>
<body>		
	<h2>选择支付方式</h2>
	<p>
		{volist name="list" id="pay"}
		<label>
			<input name="code" {if condition="$pay['code'] eq 'alipay' "} checked="checked" {/if}  value="{$pay.code}" type="radio" /> {$pay.name}
		</label>
		{/volist}
	</p>
	<button id="pay">支付</button>
</body>
<script src="__PUBLIC__/js/jquery/jquery-2.0.3.min.js"></script>
<script src="__PUBLIC__/js/jquery/jquery-migrate-1.2.1.min.js"></script>

<script>
$('#pay').click(function(){
		
var type=$("input[name='code']:checked").val();		

$.post(
	"{:url('payment/repayment/pay_api')}",
	{
		type:type,			
		ma_id:{$Request.param.pay_id}	
	},
	function(d){
		if(d.error){
			alert(d.error);
		}else if(d.pay_url){
			
			if(d.type=='wx_pay'){
					window.location.href=d.pay_url;
				}else{
					parent.window.location.href=d.pay_url;
				}
			}
		}	
	);
	
});

</script>

</script>
</html>